@extends('layouts.console_header')

@section('title', '修改角色')

@section('resources')
    @parent
<style>
	table tr td{width: 100px;height: 50px;}
</style>
@endsection

@section('content')
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;"><span style="color: #7f7f7f;"><a href="/console/index">首页</a>>后台用户管理><a href="/console/admin/account/list">角色管理</a>></span><span class="co_violet">修改</span></p>
		<a onclick="history.go(-1);" href="#"><p class="fr tc back_btn">返回</p></a>
	</div>
	<div class="role_name">
	    <input type="hidden" name="roleid" value="{{$roleid}}" />
		<p class="fz_18">角色名称</p>
		<input type="text" name="rolename" value="{{$name}}" placeholder="请输入管理组名称" readonly>
	</div>
	<div class="role_power">
		<p class="fz_18">功能权限</p>
		<span class="fz_14">请勾选属于当前管理组的功能权限</span>
		<table class="role_table" border="1" bordercolor="#d6d7dc">
            <tbody>
                <tr style="background-color: #F2F2F2;">
                    <td>
                        <input type="checkbox" class="forone" name="" value="">
                        <span>一级</span>
                    </td>
                    <td class="tc">二级</td>
                    <td class="tc">权限细则</td>
                </tr>
                <tr>
                    <td rowspan="1">
                        <input type="checkbox" name="" class="" value="">
                        <span>短信验证码查询</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>短信验证码查询</span>
                    </td>
                    <td>
                        <input type="checkbox" name="smsSelect" title="place" value="1">查看
                    </td>
                </tr>
                <tr>
                    <td rowspan="2">
                        <input type="checkbox" name="" class="" value="">
                        <span>后台用户管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>后台账号列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="adminUserManagement" title="place" value="1">查看
                        <input type="checkbox" name="adminUserManagement:add" title="place" value="1">新增

                        <input type="checkbox" name="adminUserManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="adminUserManagement:del" title="place" value="1">删除
                        <input type="checkbox" name="adminUserManagement:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>角色管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="adminRoleManagement" title="place" value="1">查看
                        <input type="checkbox" name="adminRoleManagement:add" title="place" value="1">新增
                        <input type="checkbox" name="adminRoleManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="adminRoleManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td rowspan="7">
                        <input type="checkbox" name="" class="" value="">
                        <span>系统管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>地区管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="areaManagement" title="place" value="1">查看
                        <input type="checkbox" name="areaManagement:add" title="place" value="1">新增
                        <input type="checkbox" name="areaManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="areaManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>分类管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="classManagement" title="place" value="1">查看
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>积分规则</span>
                    </td>
                    <td>
                        <input type="checkbox" name="pointManagement" title="place" value="1">查看
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>用户协议</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userAgreement" title="place" value="1">查看
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家协议</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopAgreement" title="place" value="1">查看
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>app版本</span>
                    </td>
                    <td>
                        <input type="checkbox" name="appVersion" title="place" value="1">查看
                        <input type="checkbox" name="appVersion:edit" title="place" value="1">编辑
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>红包设置</span>
                    </td>
                    <td>
                        <input type="checkbox" name="redEnvelope" title="place" value="1">查看
                        <input type="checkbox" name="redEnvelope:edit" title="place" value="1">编辑
                    </td>
                </tr>
                <tr>
                    <td rowspan="9">
                        <input type="checkbox" name="" class="" value="">
                        <span>用户版运营</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>用户列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userManagement" title="place" value="1">查看
                        <input type="checkbox" name="userManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="userManagement:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>地区用户</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userRegion" title="place" value="1">查看
                        <input type="checkbox" name="userRegion:edit" title="place" value="1">修改
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>红包管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userRedEnvelope" title="place" value="1">查看
                        <input type="checkbox" name="userRedEnvelope:edit" title="place" value="1">修改
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>Banner列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="bannerManagement" title="place" value="1">查看
                        <input type="checkbox" name="bannerManagement:add" title="place" value="1">新增
                        <input type="checkbox" name="bannerManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="bannerManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>启动页列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="appStartManagement" title="place" value="1">查看
                        <input type="checkbox" name="appStartManagement:add" title="place" value="1">新增
                        <input type="checkbox" name="appStartManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="appStartManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>热搜管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="searchManagement" title="place" value="1">查看
                        <input type="checkbox" name="searchManagement:add" title="place" value="1">新增
                        <input type="checkbox" name="searchManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="searchManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>用户帮助中心</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userHelpManagement" title="place" value="1">查看
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>用户消息管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userMessageManagement" title="place" value="1">查看
                        <input type="checkbox" name="userMessageManagement:add" title="place" value="1">新增
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>用户反馈管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userFeedbackManagement" title="place" value="1">查看
                        <input type="checkbox" name="userFeedbackManagement:edit" title="place" value="1">修改
                    </td>
                </tr>
                <tr>
                    <td rowspan="10">
                        <input type="checkbox" name="" class="" value="">
                        <span>商家版运营</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>已上架商家列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopManagement" title="place" value="1">查看
                        <input type="checkbox" name="shopManagement:add" title="place" value="1">新增
                        <input type="checkbox" name="shopManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="shopManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>审核不通过列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="staffVerifyManagement" title="place" value="1">查看
                        <input type="checkbox" name="staffVerifyManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="staffVerifyManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>待审核商家列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="verifyManagement" title="place" value="1">查看
                        <input type="checkbox" name="verifyManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="verifyManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>已下架商家管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="banShopManagement" title="place" value="1">查看
                        <input type="checkbox" name="banShopManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="banShopManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家状态记录</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopStatus" title="place" value="1">查看
                        <input type="checkbox" name="shopStatus:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>翻倍日管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="doubleDayManagement" title="place" value="1">查看
                        <input type="checkbox" name="doubleDayManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="doubleDayManagement:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>夜场管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="nightShopManagement" title="place" value="1">查看
                        <input type="checkbox" name="nightShopManagement:edit" title="place" value="1">修改
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家帮助中心</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopHelpManagement" title="place" value="1">查看
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家消息管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopMessageManagement" title="place" value="1">查看
                        <input type="checkbox" name="shopMessageManagement:add" title="place" value="1">新增
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家反馈管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopFeedbackManagement" title="place" value="1">查看
                        <input type="checkbox" name="shopFeedbackManagement:edit" title="place" value="1">修改
                    </td>
                </tr>
                <tr>
                    <td rowspan="6">
                        <input type="checkbox" name="" class="" value="">
                        <span>订单管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>充值订单列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="rechargeManagement" title="place" value="1">查看
                        <input type="checkbox" name="rechargeManagement:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>消费订单列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="orderManagement" title="place" value="1">查看
                        <input type="checkbox" name="orderManagement:export" title="place" value="1">导出
                    </td>
                </tr>

                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>全部评价列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="commentManagement" title="place" value="1">查看
                        <input type="checkbox" name="commentManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>用户退款记录</span>
                    </td>
                    <td>
                        <input type="checkbox" name="refundManagement" title="place" value="1">查看

                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>举报评价列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="reportManagement" title="place" value="1">查看
                        <input type="checkbox" name="reportManagement:edit" title="place" value="1">修改
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家回评列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopCommentManagement" title="place" value="1">查看
                        <input type="checkbox" name="shopCommentManagement:del" title="place" value="1">删除
                    </td>
                </tr>
                <tr>
                    <td rowspan="14">
                        <input type="checkbox" name="" class="" value="">
                        <span>财务中心</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>平台资金流水</span>
                    </td>
                    <td>
                        <input type="checkbox" name="ledgerAccount" title="place" value="1">查看
                        <input type="checkbox" name="ledgerAccount:add" title="place" value="1">新增
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>用户对账单</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userStatement" title="place" value="1">查看
                        <input type="checkbox" name="userStatement:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家对账单</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopStatement" title="place" value="1">查看
                        <input type="checkbox" name="shopStatement:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家待提现列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="waitWithdraw" title="place" value="1">查看
                        <input type="checkbox" name="waitWithdraw:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商家已提现列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="alreadyWithdraw" title="place" value="1">查看
                        <input type="checkbox" name="alreadyWithdraw:export" title="place" value="1">导出
                    </td>
                </tr>

                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>商务月账单</span>
                    </td>
                    <td>
                        <input type="checkbox" name="commission" title="place" value="1">查看
                        <input type="checkbox" name="commission:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value=""><!-- //TODO -->
                        <span>地推对账单</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopSalesmanStatement" title="place" value="1">查看
                        <input type="checkbox" name="shopSalesmanStatement:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>地推待提现</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopSalesmanWaitWithdrawal" title="place" value="1">查看
                        <input type="checkbox" name="shopSalesmanWaitWithdrawal:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>地推已提现</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopSalesmanWithdrawal" title="place" value="1">查看
                        <input type="checkbox" name="shopSalesmanWithdrawal:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>代理商分润</span>
                    </td>
                    <td>
                        <input type="checkbox" name="agentProfit" title="place" value="1">查看

                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>代理商对账单</span>
                    </td>
                    <td>
                        <input type="checkbox" name="agentStatement" title="place" value="1">查看

                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>代理商待提现</span>
                    </td>
                    <td>
                        <input type="checkbox" name="agentWaitWithdrawal" title="place" value="1">查看
                        <input type="checkbox" name="agentWaitWithdrawal:edit" title="place" value="1">编辑
                        <input type="checkbox" name="agentWaitWithdrawal:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>代理商已提现</span>
                    </td>
                    <td>
                        <input type="checkbox" name="agentWithdrawal" title="place" value="1">查看
                        <input type="checkbox" name="agentWithdrawal:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>代理收款账号管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="agentReceivableManage" title="place" value="1">查看
                        <input type="checkbox" name="agentReceivableManage:edit" title="place" value="1">编辑
                    </td>
                </tr>

                <tr>
                    <td rowspan="3">
                        <input type="checkbox" name="" class="" value="">
                        <span>地推管理</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>地推商家列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="shopSalesmanManagement" title="place" value="1">查看
                        <input type="checkbox" name="shopSalesmanManagement:add" title="place" value="1">新增
                        <input type="checkbox" name="shopSalesmanManagement:edit" title="place" value="1">修改
                        <input type="checkbox" name="shopSalesmanManagement:del" title="place" value="1">删除
                        <input type="checkbox" name="shopSalesmanManagement:export" title="place" value="1">导出
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>个人地推列表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="userSalesmanManagement" title="place" value="1">查看
                        <input type="checkbox" name="userSalesmanManagement:edit" title="place" value="1">编辑
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>地推设置</span>
                    </td>
                    <td>
                        <input type="checkbox" name="salesmanSetManagement" title="place" value="1">查看
                        <input type="checkbox" name="salesmanSetManagement:edit" title="place" value="1">编辑
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" name="" class="" value="">
                        <span>数据报表</span>
                    </td>
                    <td>
                        <input type="checkbox" name="" title="place" class="place" value="">
                        <span>统计概况</span>
                    </td>
                    <td>
                        <input type="checkbox" name="statistical" title="place" value="1">查看
                    </td>
                </tr>
            </tbody>
        </table>
	</div>
	<button id="preserve" style="background-color: #9955c6;margin-right: 870px;">保存</button>
	<a onclick="history.go(-1);" href=""><button>取消</button></a>
</section>
@endsection

@section('scriptResources')
    @parent
    <!-- js 文件-->
<script>
    var cityid='{{$cityid}}';
    var auth='{{$auth}}';
    //获取已有权限并全部勾上
    auth = auth.replace(/&quot;/gm,'"');
    auth = eval("("+auth+")");
    for (var i = 0; i < $("input[value=1]").length; i++) {
    	for (var j = 0; j < auth.length; j++) {
    		if($("input[value=1]").eq(i).attr("name") == auth[j]){
    			$("input[value=1]").eq(i).attr("checked",true);
    		}
    	};
    };
    //保存修改后权限
	var authout=[];
	$("#preserve").on("click",function(){
		authout=[]
		for (var i = 0; i < $("input[type='checkbox']").length; i++) {
			if($("input[type='checkbox']").eq(i).is(":checked") == true){
				authout.push($("input[type='checkbox']").eq(i).attr("name"))
			}else{
				continue;
			}
		};
		console.log(authout);
		var auth_json = JSON.stringify(authout);
		var rolename = $("input[name='rolename']").val();
		var roleid = $("input[name='roleid']").val();
	    $.ajax({
            url : '/console/admin/role/edit',
            data:{
                cityid:cityid,
                roleid:roleid,
                rolename:rolename,
                auth:auth_json,
                action:'edit'
            },
            dataType:'json',
            type:'post',
            success:function(data){
                if(data.status == 'failed') {
                    alert(data.message);
                } else {
                    alert(data.message);
                    window.location.href="/console/admin/role/management?cityid=" + cityid + "&now=" + new Date().getTime();
                }
            }
        });
	})
</script>
@endsection